home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / include / sys / RCS / file.h,v < prev    next >
Text File  |  1991-03-29  |  5KB  |  222 lines

  1. head     1.5;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.5
  10. date     91.03.29.18.06.32;  author shirriff;  state Exp;
  11. branches ;
  12. next     1.4;
  13.  
  14. 1.4
  15. date     89.07.14.09.15.22;  author rab;  state Exp;
  16. branches ;
  17. next     1.3;
  18.  
  19. 1.3
  20. date     88.09.30.08.23.24;  author brent;  state Exp;
  21. branches ;
  22. next     1.2;
  23.  
  24. 1.2
  25. date     88.06.29.14.47.58;  author ouster;  state Exp;
  26. branches ;
  27. next     1.1;
  28.  
  29. 1.1
  30. date     88.06.21.16.12.51;  author ouster;  state Exp;
  31. branches ;
  32. next     ;
  33.  
  34.  
  35. desc
  36. @@
  37.  
  38.  
  39. 1.5
  40. log
  41. @Added fcntl options used by sunOS.
  42. @
  43. text
  44. @/*
  45.  * Copyright (c) 1982, 1986 Regents of the University of California.
  46.  * All rights reserved.  The Berkeley software License Agreement
  47.  * specifies the terms and conditions for redistribution.
  48.  *
  49.  *    @@(#)file.h    7.1 (Berkeley) 6/4/86
  50.  */
  51.  
  52. #ifndef _FILE
  53. #define _FILE
  54.  
  55. /*
  56.  * flags- also for fcntl call.
  57.  */
  58. #define    FOPEN        (-1)
  59. #define    FREAD        00001        /* descriptor read/receive'able */
  60. #define    FWRITE        00002        /* descriptor write/send'able */
  61. #ifndef    F_DUPFD
  62. #define    FNDELAY        00004        /* no delay */
  63. #define    FAPPEND        00010        /* append on each write */
  64. #endif
  65. #define    FMARK        00020        /* mark during gc() */
  66. #define    FDEFER        00040        /* defer for next gc pass */
  67. #ifndef    F_DUPFD
  68. #define    FASYNC        00100        /* signal pgrp when data ready */
  69. #endif
  70. #define    FSHLOCK        00200        /* shared lock present */
  71. #define    FEXLOCK        00400        /* exclusive lock present */
  72.  
  73. /* bits to save after open */
  74. #define    FMASK        00113
  75. #define    FCNTLCANT    (FREAD|FWRITE|FMARK|FDEFER|FSHLOCK|FEXLOCK)
  76.  
  77. /* open only modes */
  78. #define    FCREAT        01000        /* create if nonexistant */
  79. #define    FTRUNC        02000        /* truncate to zero length */
  80. #define    FEXCL        04000        /* error if already created */
  81.  
  82. #ifndef    F_DUPFD
  83. /* fcntl(2) requests--from <fcntl.h> */
  84. #define    F_DUPFD    0    /* Duplicate fildes */
  85. #define    F_GETFD    1    /* Get fildes flags */
  86. #define    F_SETFD    2    /* Set fildes flags */
  87. #define    F_GETFL    3    /* Get file flags */
  88. #define    F_SETFL    4    /* Set file flags */
  89. #define    F_GETOWN 5    /* Get owner */
  90. #define F_SETOWN 6    /* Set owner */
  91. #define    F_GETLK    7    /* Get record-lock info */
  92. #define    F_SETLK    8    /* Set or clear a record-lock */
  93. #define    F_SETLKW    9    /* Set or clear a record-lock (blocking) */
  94. #define    F_RGETLK    10    /* Test if lock blocked */
  95. #define    F_RSETLK    11    /* Set or unlock lock */
  96. #define    F_CNVT        12    /* Convert fhandle to fd */
  97. #define    F_RSETLKW    13    /* Set or clear remote lock (blocking) */
  98.  
  99. #endif
  100.  
  101. /*
  102.  * User definitions.
  103.  */
  104.  
  105. /*
  106.  * Open call.
  107.  */
  108. #define    O_RDONLY    000        /* open for reading */
  109. #define    O_WRONLY    001        /* open for writing */
  110. #define    O_RDWR        002        /* open for read & write */
  111. #define    O_NDELAY    FNDELAY        /* non-blocking open */
  112. #define    O_APPEND    FAPPEND        /* append on each write */
  113. #define    O_CREAT        FCREAT        /* open with file create */
  114. #define    O_TRUNC        FTRUNC        /* open with truncation */
  115. #define    O_EXCL        FEXCL        /* error on create if file exists */
  116. #define O_MASTER    010000        /* open pseudo-device as master */
  117. #define O_PFS_MASTER    020000        /* open as pseudo-filesystem master */
  118.  
  119. /*
  120.  * Flock call.
  121.  */
  122. #define    LOCK_SH        1    /* shared lock */
  123. #define    LOCK_EX        2    /* exclusive lock */
  124. #define    LOCK_NB        4    /* don't block when locking */
  125. #define    LOCK_UN        8    /* unlock */
  126.  
  127. /*
  128.  * Access call.
  129.  */
  130. #define    F_OK        0    /* does file exist */
  131. #define    X_OK        1    /* is it executable by caller */
  132. #define    W_OK        2    /* writable by caller */
  133. #define    R_OK        4    /* readable by caller */
  134.  
  135. /*
  136.  * Lseek call.
  137.  */
  138. #define    L_SET        0    /* absolute offset */
  139. #define    L_INCR        1    /* relative to current offset */
  140. #define    L_XTND        2    /* relative to end of file */
  141.  
  142. #endif /* _FILE */
  143. @
  144.  
  145.  
  146. 1.4
  147. log
  148. @*** empty log message ***
  149. @
  150. text
  151. @d48 8
  152. @
  153.  
  154.  
  155. 1.3
  156. log
  157. @Added O_PFS_MASTER flag for pseudo-filesytem implementation
  158. @
  159. text
  160. @d91 1
  161. a91 1
  162. #endif _FILE
  163. @
  164.  
  165.  
  166. 1.2
  167. log
  168. @Add ifdefs to prevent files from being included multiple times.
  169. @
  170. text
  171. @d66 1
  172. @
  173.  
  174.  
  175. 1.1
  176. log
  177. @Initial revision
  178. @
  179. text
  180. @d9 2
  181. a10 19
  182. #ifdef KERNEL
  183. /*
  184.  * Descriptor table entry.
  185.  * One for each kernel object.
  186.  */
  187. struct    file {
  188.     int    f_flag;        /* see below */
  189.     short    f_type;        /* descriptor type */
  190.     short    f_count;    /* reference count */
  191.     short    f_msgcount;    /* references from message queue */
  192.     struct    fileops {
  193.         int    (*fo_rw)();
  194.         int    (*fo_ioctl)();
  195.         int    (*fo_select)();
  196.         int    (*fo_close)();
  197.     } *f_ops;
  198.     caddr_t    f_data;        /* inode */
  199.     off_t    f_offset;
  200. };
  201. a11 6
  202. struct    file *file, *fileNFILE;
  203. int    nfile;
  204. struct    file *getf();
  205. struct    file *falloc();
  206. #endif
  207.  
  208. d65 1
  209. d90 1
  210. a90 10
  211. #ifdef KERNEL
  212. #define    GETF(fp, fd) { \
  213.     if ((unsigned)(fd) >= NOFILE || ((fp) = u.u_ofile[fd]) == NULL) { \
  214.         u.u_error = EBADF; \
  215.         return; \
  216.     } \
  217. }
  218. #define    DTYPE_INODE    1    /* file */
  219. #define    DTYPE_SOCKET    2    /* communications endpoint */
  220. #endif
  221. @
  222.